package com.example.interceptor;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.model.Song;
import com.example.utils.ResultVOUtil;

@RestController
@RequestMapping("two")
public class TwoController {

	@RequestMapping("test")
	public Object test() {

		Song song = new Song();
		song.setName("龙拳2");
		song.setSinger("周杰伦");
		song.setCreatetime(new Date().getTime());
		song.setUpdatetime(new Date().getTime());

		Song song2 = new Song();
		song2.setName("醉赤壁2");
		song2.setSinger("林俊杰");
		song2.setCreatetime(new Date().getTime());
		song2.setUpdatetime(new Date().getTime());

		Song song3 = new Song();
		song3.setName("美人鱼2");
		song3.setSinger("林俊杰");
		song3.setCreatetime(new Date().getTime());
		song3.setUpdatetime(new Date().getTime());

		List<Song> songList = new ArrayList<>();
		songList.add(song);
		songList.add(song2);
		songList.add(song3);

		Map<String, Object> resultMap = new HashMap<>();
		resultMap.put("songList", songList);

		return ResultVOUtil.success(resultMap);
	}

	@PostMapping("postform")
	public String postform(Song song) {
		System.out.println(song.getName());
		return "redirect:/th/test";
	}
}